<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
<link rel="stylesheet" type="text/css" media="screen"
	href="<c:url value='/resources/css/coolblue.css' />" />
<title>My Crews</title>
</head>
<body>
	<div id="content-wrap">

		<!-- content -->
		<div id="content" class="clearfix">
			<%@ include file="./common.jsp"%>
			<div id="main">
				<c:choose>
					<c:when test="${!empty mycrewlist}">
						<h3>My Crews</h3>
						<div id="existingCrews">
							<table>
								<tr>
									<th>Name</th>
									<th>Members</th>
									<th>Action</th>
								</tr>
								<c:forEach var="crew" items="${mycrewlist}">
									<tr style="height: 10px; padding: 1">
										<td style="height: 10px; padding: 1">${crew.name}</td>
										<td style="height: 10px; padding: 1"><c:forEach var="member" items="${crew.members}">${member.user.firstName} ${member.user.lastName}<br />
											</c:forEach></td>
										<td style="height: 10px; padding: 1"><c:url var="deleteUrl" value="/mycrews/remove" />
											<form
												style="width: 20px; background: #FFF; height: 10px; border: none; padding: 1"
												id="${crew.id}" action="${deleteUrl}" method="POST">
												<input style="color: red" id="crew" name="crew"
													type="hidden" value="${crew.id}" /> <input type="submit"
													value="Delete" />
											</form></td>
									</tr>
								</c:forEach>
							</table>
						</div>
					</c:when>
					<c:otherwise>
						<p>You currently do not have any crews.</p>
					</c:otherwise>
				</c:choose>
				<h3>Create Crew</h3>
				<div id="newCrew">
					<form:form action="mycrews.html" method="post"
						modelAttribute="newCrewForm">
						<form:errors path="*" element="div" />
						<table>
							<tr>
								<td><form:label path="name">Name</form:label></td>
								<td><form:input path="name" /></td>
							</tr>
							<tr>
								<td><form:label path="members">Members</form:label></td>
								<td><form:select multiple="true" path="members">
										<form:options items="${memberOptions}" />
									</form:select></td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" value="Create Crew" /></td>
							</tr>
						</table>
					</form:form>
				</div>
			</div>
		</div>
	</div>
</body>
</html>